name: {{ beat_hostname }}
logging.level: info
logging.to_files: true
logging.files:
  path: {{ logs_path }}/filebeat
  name: filebeat
  keepfiles: 7
  permissions: 0644

{% set mhosts=[] %}
{%- for host in groups.kafka -%}
{{ mhosts.append('"'+hostvars[host]['ansible_host']+':9092'+'"') }}
{%- endfor -%}
output.kafka:
  enabled: true
  hosts: [{{ mhosts|join(',') }}]
  topic: "%{[fields][log_topic]}"
  partition.hash:
    reachable_only: true
  compression: gzip
  max_message_bytes: 1000000
  required_acks: 1
logging.to_files: true

filebeat.config.inputs:
  enabled: true
  path: conf.d/*.yml

{% set nhosts=[] %}
{%- if groups.elasticMaster -%}
{%- for host in groups.elasticMaster -%}
{{ nhosts.append('"'+hostvars[host]['ansible_host']+':9200'+'"') }}
{%- endfor -%}
{%- elif groups.elasticsearch -%}
{%- for host in groups.elasticsearch -%}
{{ nhosts.append('"'+hostvars[host]['ansible_host']+':9200'+'"') }}
{%- endfor -%}
{%- endif -%}
xpack.monitoring:
  enabled: true
  elasticsearch:
    hosts: [{{ nhosts|join(',') }}]